package com.example.tys.baseapplication.util;

import android.util.TypedValue;

import com.example.tys.baseapplication.MyApp;

/**
 * Created by tys on 2017/10/14.
 */

public class DisplayUtil {
    private static int SCREE_WIDTH;
    private static int SCREE_HEIGHT;

    public static int screeWidth() {
        if (SCREE_WIDTH <= 0) {
            SCREE_WIDTH = MyApp.getInstance().getResources().getDisplayMetrics().widthPixels;
        }
        return SCREE_WIDTH;
    }

    public static int screeHeight() {
        if (SCREE_HEIGHT <= 0) {
            SCREE_HEIGHT = MyApp.getInstance().getResources().getDisplayMetrics().heightPixels;
        }
        return SCREE_HEIGHT;
    }


    public static float dp2px(int dip) {
        return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip,
                MyApp.getInstance().getResources().getDisplayMetrics());
    }



}
